package com.design.movieticket.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.design.movieticket.dto.HallListDto;
import com.design.movieticket.dto.MovieArrangeDto;
import com.design.movieticket.entity.MovieArrange;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;

public interface MovieArrangeMapper extends BaseMapper<MovieArrange> {
    /** 获取影厅id */
    @Select("select id from cinema where principal = #{principal}")
    public Long getCinemaIdByPrincipal(String principal);

    /** 获取影厅列表 */
    @Select("select id,hall_name,status from movie_hall where cinema_id = #{cinemaId} and del_flag!=1")
    public List<HallListDto> getHallList(Long cinemaId);

    /** 获取场次信息列表 */
    @Select("select * from movie_arrange where movie_name=#{movieName} and movie_hall_id=#{hallId} and del_flag=0 and start_time between #{dateOne} and #{dateTwo}" +
            "order by start_time")
    public List<MovieArrange> getTableData(String movieName, Long hallId, String dateOne, String dateTwo);



    /** 小程序获取具体影院排片场次 */
    @Select("SELECT a.*,b.hall_name as movieHallName FROM movie_arrange a " +
            "left join movie_hall b " +
            "on a.movie_hall_id = b.id " +
            "where a.movie_hall_id in " +
            "(select id from movie_hall where cinema_id = #{cinemaId} and status=1 and del_flag=0)" +
            "and a.start_time BETWEEN #{dayNowTime} and #{dayEndTime} and a.movie_name = #{movieName} and a.del_flag = 0 " +
            "ORDER BY a.start_time")
    List<MovieArrangeDto> wxGetMovieArrangeListByCinemaIdAndMovieName(Long cinemaId,String dayNowTime, String dayEndTime, String movieName);
}
